//
//  main.m
//  OC03-HomeWork
//
//  Created by dllo on 16/7/6.
//  Copyright © 2016年 高雅馨. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Books.h"
#import "BookManager.h"
int main(int argc, const char * argv[]) {
    /**
     *  1⃣️截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
     */
    NSString *strSP = @"20|http://www.baidu.com";
    NSArray *strCP =
    [strSP componentsSeparatedByString:@"|"];
    NSLog(@"%@",strCP);
    /**
     * 2⃣️向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
     */
    int a = 8;
    NSNumber *aNum = [NSNumber numberWithInt:a];
    float b = 9.66;
    NSNumber *bNum = [NSNumber numberWithFloat:b];
    double c = 10.7894561;
    NSNumber *cNum = [NSNumber numberWithDouble:c];
    bool d = 1;
    NSNumber *dNum = [NSNumber numberWithBool:d];
    NSMutableArray *mutArr = [NSMutableArray arrayWithObjects:aNum, bNum, cNum, dNum, nil];
    NSLog(@"%@", mutArr);
    /**
     *  3⃣️实现图书管理系统(BookManager类)：
     1、使用数组管理所有书籍(Book类)。
     2、BookManager类属性数组可以添加、删除。
     3、可以从数组根据书名查找书籍，并修改书籍的价格。
     4、展示所有书籍清单（书名）
     */
    Books *book1 = [Books booksWithName:@"不负如来不负卿" Price:88.8];
    Books *book2 = [Books booksWithName:@"木槿花西月锦绣" Price:99.9];
    Books *book3 = [Books booksWithName:@"淡极始知花更艳" Price:77.7];
    Books *book4 = [Books booksWithName:@"山雨欲来风满楼"Price:66.6];
    BookManager *bookManager = [[BookManager alloc] init];
    bookManager.bookArr = [NSMutableArray array];
    [bookManager.bookArr addObject:book1];
    [bookManager.bookArr addObject:book2];
    [bookManager.bookArr addObject:book3];
    [bookManager.bookArr addObject:book4];
    [bookManager display];
    [bookManager.bookArr removeObject:book1];
    [bookManager display];
    for (Books *arr in bookManager.bookArr) {
        if ([arr.name isEqualToString:@"山雨欲来风满楼"]) {
            arr.price = 66.0;
        }
        NSLog(@"书名:%@价格改为:%f", arr.name, arr.price);
    }
    return 0;
}
